package tech.aistar.service;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import tech.aistar.entity.Post;

import java.lang.ref.PhantomReference;
import java.util.Date;

/**
 * Created by Administrator on 2019/10/8.
 */
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class PostTest {
    @Autowired
    private IPostService postService;
    @Autowired
    private IThemeService themeService;

    @Test
    public void testTheme(){
        themeService.findAllTheme();
        System.err.println(themeService.findAllTheme());
    }

    @Test
    public void test1(){
        //查询所有
        postService.findAllPost();
        System.err.println(postService.findAllPost());
    }
    @Test
    public void test2(){
        //添加帖子
        Post post = new Post();
        post.setThemeId(4);
        post.setClassId(1);
        post.setPostContent("" +
                "<p>可以html和text的方式读取编辑器的内容</p><br>" +
                "<p>欢迎使用 wangEditor 编辑器</p><br>" +
                "<p>wangEditor 从v3版本开始不支持 textarea ，</p><br>" +
                "<p>但是可以通过onchange来实现 textarea 中提交富文本内容。</p><br>" +
                "<p>欢迎使用 <b>wangEditor</b> 富文本编辑器</p><br>" +
                "<p>欢迎使用 <b>wangEditor</b> 富文本编辑器</p><br>");
        post.setPointNum(6513);
        post.setVisitNum(165);
        post.setUserId(2);
        post.setStatus(0);
        post.setTitle("第一次发帖");
        post.setPtime(new Date());
        postService.savePost(post);
    }
    
}
